package com.situ.day250110;

import org.junit.Test;

import java.util.Scanner;

public class Demo2 {
    @Test
    public void test1() {

        int i = 1;
        while (i <= 5) {
            System.out.println(i);
            i++;
        }
    }
    @Test
    public void test2() {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入月份：");
        int month = sc.nextInt();
        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                System.out.println("31天");
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                System.out.println("30天");
                break;
            case 2:
                System.out.println("请输入年份：");
                int year = sc.nextInt();
                break;
            default:
                System.out.println("default");
                break;

        }
    }
    @Test
    public void test3() {
        int sum = 0;
        for (int i = 1; i <= 100; i++) {
            System.out.println(i);
            sum += i;
            System.out.println("sum: " + sum);
        }
        System.out.println("sum: " + sum);
    }
    //统计思想，数一下符合条件的有多少个（计算1-100以内7的倍数的个数）
    @Test
    public void test4() {
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            if (i % 7 == 0) {
                System.out.println(i);
                count++;
            }
        }
        System.out.println("count: " + count);
    }
    @Test
    public void test5() {
        for (int i = 1; i <= 5; i++) {
            if (i == 3) {
                break;
            }
            System.out.println(i);
        }
    }
}
